package leetcode.tencent.hot50;

import common.ListNode;
import utils.MyUtil;

/**
 * Created on 2021/1/4 。
 *
 * @author wll 1978992154@qq.com
 */

public class DelLinkNode {
    /**
     * 删除列表中值为对应值的节点
     * @param node 需要删除的节点
     */
    public static void deleteNode(ListNode node,int val){
        while (node.next != null){
            if (node.val == val){
                node.next = node.next.next;
            }
            node = node.next;
        }

    }


    public static void main(String[] args) {
        ListNode pHead = new ListNode();
        ListNode pTmp = pHead;
        for (int i = 1; i < 11; i++) {
            ListNode tmp = new ListNode(i);
            pTmp.next = tmp;
            pTmp = pTmp.next;
        }
        MyUtil.displayListNode(pHead);
        deleteNode(pHead,5);
        MyUtil.displayListNode(pHead);
    }
}


